package com.msconfig.event;

import com.geo.msconfig.R;
import com.msconfig.MyApplication;

import org.greenrobot.eventbus.EventBus;

//发送消息
public class DeviceUpdateUINotify {
	/**
	 * 连接设备的结果
	 * @param success 是否连接上
	 */
	public static void eventDeviceConnectResult(boolean success) {
		DeviceUpdateEvent.DeviceConnectResultStatus resultStatus = new DeviceUpdateEvent.DeviceConnectResultStatus(success);
		EventBus.getDefault().post(resultStatus);
	}

	/**
	 * 断开设备的连接
	 */
	public static void eventDeviceDisConnectResult() {
		DeviceUpdateEvent.DeviceDisConnectResultStatus disconnectStatus = new DeviceUpdateEvent.DeviceDisConnectResultStatus();
		EventBus.getDefault().post(disconnectStatus);
	}

	/*
	 * 更新定位信息
	 */
	public static void eventUpdateLocationResult() {
		DeviceUpdateEvent.UpdateLocationResultStatus updateStatus = new DeviceUpdateEvent.UpdateLocationResultStatus();
		EventBus.getDefault().postSticky(updateStatus);
	}

	public static void eventDeviceCommandSend(int status, String strFunction) {
		//获取电量命令,GTEALL,获取数据回传状态不需要更新界面，防止打扰设置页面
		if(strFunction.equals(MyApplication.getGlobalContext().getString(R.string.function_get_power_level)) ||
				strFunction.equals(MyApplication.getGlobalContext().getString(R.string.function_get_all)) ||
				strFunction.equals(MyApplication.getGlobalContext().getString(R.string.function_get_raw_result_status))){
			return;
		}
		DeviceUpdateEvent.DeviceCommandSendStatus commandSendStatus = new DeviceUpdateEvent.DeviceCommandSendStatus(status, strFunction);
		EventBus.getDefault().postSticky(commandSendStatus);
	}

	//自动连接
	public static void eventAutoConnect() {
		DeviceUpdateEvent.AutoConnectEvent autoConnectEvent = new DeviceUpdateEvent.AutoConnectEvent();
		EventBus.getDefault().postSticky(autoConnectEvent);
	}

	/*
	 * GETALL成功返回 OK
	 *
	 * */
	public static void eventUpdateDialogGetRtkSuccess() {
		DeviceUpdateEvent.UpdateDialogGetRtkSuccessStatus getRtkSuccessStatus = new DeviceUpdateEvent.UpdateDialogGetRtkSuccessStatus();
		EventBus.getDefault().postSticky(getRtkSuccessStatus);
	}

	/*
	 * 获取电池电量 OK
	 *
	 * */
	public static void eventUpdateDialogGetPowerLevelSucc() {
		DeviceUpdateEvent.UpdateDialogGetPowerLevelSuccessStatus getRtkSuccessStatus = new DeviceUpdateEvent.UpdateDialogGetPowerLevelSuccessStatus();
		EventBus.getDefault().postSticky(getRtkSuccessStatus);
	}

	/*
	 * 数据回传状态 OK
	 *
	 * */
	public static void eventUpdateDialogGetDataRawResultSucc() {
		DeviceUpdateEvent.UpdateDialogGetDataRawResultSuccessStatus getRtkSuccessStatus = new DeviceUpdateEvent.UpdateDialogGetDataRawResultSuccessStatus();
		EventBus.getDefault().postSticky(getRtkSuccessStatus);
	}

	/*
	 * 更新卫星信息
	 *
	 * */
	public static void eventUpdateSatelliteResult() {
		DeviceUpdateEvent.UpdateSatelliteResultStatus satelliteResultStatus = new DeviceUpdateEvent.UpdateSatelliteResultStatus();
		EventBus.getDefault().postSticky(satelliteResultStatus);
	}

}
